<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Multi-Threaded Applications</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Getting Started with Distributed Berkeley DB Applications" />
    <link rel="up" href="client.html" title="Chapter 3. Berkeley DB Client Driver APIs" />
    <link rel="prev" href="client.secondary.html" title="Secondary Databases" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 12.1.6.2</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Multi-Threaded Applications</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="client.secondary.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 3. Berkeley DB Client Driver APIs</th>
          <td width="20%" align="right"> </td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="client.concurrency"></a>Multi-Threaded Applications</h2>
          </div>
        </div>
      </div>
      <p> 
            The <code class="classname">BdbServerConnection</code> class is not
            thread-safe. Furthermore, objects created from a
            <code class="classname">BdbServerConnection</code> instance use the
            connection object internally for remote invocations. Therefore, they
            are not thread-safe either. The connection object together with all
            objects created from it must be used in a single thread, because
            they all share the same connection object. For example, if we create
            a <code class="classname">BdbServerAdmin</code> object, a
            <code class="classname">SEnvironment</code> object from a
            <code class="classname">BdbServerConnection</code> object, a
            <code class="classname">SDatabase</code> object, and a
            <code class="classname">STransaction</code> object from the
            <code class="classname">SEnvironment</code> object, all five objects
            must be accessed in a single thread.
        </p>
      <p> 
            For a multi-threaded application, you can create multiple
            instances of <code class="classname">BdbServerConnection</code> each in a
            separate thread. Then, if necessary, you can open the same
            environment or database from multiple connections to access the same
            environment or database concurrently.
        </p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="client.secondary.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="client.html">Up</a>
          </td>
          <td width="40%" align="right"> </td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Secondary Databases </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> </td>
        </tr>
      </table>
    </div>
  </body>
</html>
